import sys

from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QMainWindow, QLabel, QPushButton, QFileDialog, QApplication
from ultralytics import YOLO
import cv2 as cv
import numpy as np
from PyQt5 import QtCore, QtWidgets


model =YOLO("D:\\Codes\\ultralytics-main\\runs\\detect\\train36\\weights\\best.pt")
# D:\\yyyyyyy\\code\\ultralytics-main\\yolov8n.pt
#D:\\yyyyyyy\\code\\ultralytics-main\\runs\\detect\\train3\\weights\\best.pt


results = model.predict(source="D:\\tiger1.jpg", epochs=5,
                                imgsz=640,
                                batch=1)
for result in results:
            # 获取原始图像
            img = result.orig_img
            # 绘制预测结果
            annotated_image = result.plot()
            # 显示预测结果
            cv.imshow("Predicted Image", annotated_image)
            cv.waitKey(0)
            cv.destroyAllWindows()

